﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Jack.EntityFrameworkCore
{
    public interface IRepository
#if DEBUG
        : IDisposable
#endif
    {
    }

    public interface IRepository<TModel> : IQueryable<TModel>, IEnumerable<TModel>, IEnumerable, IQueryable, IRepository
        where TModel : class, IBaseModel, new()
    {
        void Delete(TModel model);

        void Delete<TKey>(params TKey[] ids);

        void Delete(Expression<Func<TModel, bool>> predicate);

        void DeleteMany(IEnumerable<TModel> models);

        Task<TModel> Get(Expression<Func<TModel, bool>> expression, CancellationToken cancellationToken = default);

        Task<List<TModel>> GetList(CancellationToken cancellationToken = default);

        Task<List<TModel>> GetList(Expression<Func<TModel, bool>> expression, CancellationToken cancellationToken = default);

        Task<List<TModel>> GetPageList(Expression<Func<TModel, bool>> expression, int skipCount, int maxResultCount, string sorting, CancellationToken cancellationToken = default);

        Task<List<TModel>> GetPageList(int skipCount, int maxResultCount, string sorting, CancellationToken cancellationToken = default);

        Task<TModel> Insert(TModel model, CancellationToken cancellationToken = default);

        Task InsertMany(IEnumerable<TModel> models, CancellationToken cancellationToken = default);

        TModel Update(TModel model);

        void UpdatePartial(TModel model, params Expression<Func<TModel, object>>[] properties);

        void UpdatePartial(TModel model, params string[] properties);

        void UpdatePartialByExclude(TModel model, params string[] excludeProperties);

        void UpdateMany(IEnumerable<TModel> models);
    }
}
